﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SortOf;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {

        private void tester(ISort sort)
        {
            List<int> onzin = new List<int>()
            {
                50, 10, 40, 37, 120, 125, 9, 47, 57
            };

            sort.Apply(onzin);

            List<int> correct = new List<int>()
            {
                9, 10, 37, 40, 47, 50, 57, 120, 125
            };

            Assert.AreEqual(correct.Count, onzin.Count);

            for (int i = 0; i < onzin.Count; i++)
            {
                Assert.AreEqual(correct[i], onzin[i]);
            }
        }
        /*
        private void tester(MergeSort sort)
        {
            List<int> onzin = new List<int>()
            {
                50, 10, 40, 37, 120, 125, 9, 47, 57
            };

            sort.Apply(onzin);

            List<int> correct = new List<int>()
            {
                9, 10, 37, 40, 47, 50, 57, 120, 125
            };

            Assert.AreEqual(correct.Count, onzin.Count);

            for (int i = 0; i < onzin.Count; i++)
            {
                Assert.AreEqual(correct[i], onzin[i]);
            }
        }*/

        [TestMethod]
        public void TestBubbleSort()
        {
            tester(new BubbleSort());
        }

        [TestMethod]
        public void TestSelectionSort()
        {
            tester(new SelectionSort());
        }

        [TestMethod]
        public void TestInsertionSort()
        {
            tester(new InsertionSort());
        }

        [TestMethod]
        public void TestShellSort()
        {
            tester(new ShellSort());
        }

        [TestMethod]
        public void TestMergeSort()
        {
            tester(new MergeSort());
        }

        [TestMethod]
        public void TestHeapSort()
        {
            tester(new HeapSort());
        }

        [TestMethod]
        public void TestQuickSort()
        {
            tester(new QuickSort());
        }
    }
}
